import timeFrom from '@/uview-ui/libs/function/timeFrom.js'
import QQMapWX from '@/common/qqmap-wx-jssdk.js'

const tMap = new QQMapWX({
	key: '2NQBZ-RMHLG-YTMQD-IIHNV-NBHE5-6YB2U' //开发者密钥
});

let reverseGeocoder = function(info) {
	tMap.reverseGeocoder(info)
}

let geocoder = function(address) {
	return new Promise((resolve, reject) => {
		//调用地址解析接口
		tMap.geocoder({
			//获取表单传入地址
			address: address, //地址参数，例：固定地址，address: '北京市海淀区彩和坊路海淀西大街74号'
			success: function(res) { //成功后的回调
				resolve(res.result)
			},
			fail: function(error) {
				console.error(error);
				reject(error)
			},
			complete: function(res) {
				console.log(res);
			}
		})
	})
}

const install = (Vue, vm) => {
	Vue.prototype.$func = {
		timeFrom,
		reverseGeocoder,
		geocoder
	}
}

export default {
	install
}
